package com.design.factoryPattern;

public class FruitFactoryDemo {
    public static void main(String[] args) {
        Fruit apple = new AppleFactory().createFruit();
        apple.fruitKinds();
        Fruit banana = new BananaFactory().createFruit();
        banana.fruitKinds();
    }
}
interface Fruit {
    void fruitKinds();
}

class Apple implements Fruit {
    public void fruitKinds(){
        System.out.println("苹果");
    }
}

class Banana implements Fruit {
    public void fruitKinds(){
        System.out.println("香蕉");
    }
}

interface FruitFactory {
    Fruit createFruit();
}

class AppleFactory implements FruitFactory {
    public Fruit createFruit() {
        return new Apple();
    }
}

class BananaFactory implements FruitFactory {
    public Fruit createFruit() {
        return new Banana();
    }
}
